package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TsurveyanswerDao;
import com.xy.manage.model.Tsurveyanswer;
import com.xy.manage.model.Tsurveyquestion;
import com.xy.manage.service.TsurveyanswerService;

@Service
@Transactional
public class TsurveyanswerServiceImpl extends BaseServiceImpl<Tsurveyanswer> implements
		TsurveyanswerService {
	private TsurveyanswerDao tsurveyanswerDao;

	public TsurveyanswerServiceImpl(TsurveyanswerDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tsurveyanswerDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tsurveyanswerDao.checkExist("Tsurveyanswer", paraName, paraValue);
	}

	@Override
	public List<Tsurveyanswer> getTsurveyanswer(Map<String, Object> map) {
		return tsurveyanswerDao.getTsurveyanswer(map);
	}
	@Override
	public Pagination getTsurveyanswerByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tsurveyanswerDao.getTsurveyanswerByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tsurveyanswer save(Tsurveyanswer tsurveyanswer) {
	//	tsurveyanswer.setModtime(new Date());
		if(tsurveyanswer.getAnswerid()==null){
			//新增
        	return super.save(tsurveyanswer);
		}else{
			//更新
			Tsurveyanswer tsurveyanswer1=tsurveyanswerDao.get(tsurveyanswer.getAnswerid());
			try {
				BeanUtil.copyNotNullProperties(tsurveyanswer1, tsurveyanswer);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tsurveyanswer1);
		}
	}

	@Override
	public Tsurveyquestion getCount(Tsurveyquestion tsurveyquestion) {
		return tsurveyanswerDao.getCount(tsurveyquestion);
	}
}